<?php
namespace app\model;

use think\Model;

class Common extends Model
{
	protected $pk = "id";
	protected $autoWriteTimestamp = true;
	protected $auto = [];
    protected $insert = ['ip','status' => 1, 'is_admin' => 0];  
    protected $update = [];  
    
    protected function setIpAttr()
    {
        return request()->ip();
    }
    /**
     * 对密码进行加密
     */
    protected function setPasswordAttr($val){
    	return md5('tp'.sha1($val).'tp');
    }
    /**
     * @param  [type] $code [状态码:200 正常 非200 错误]
     * @param  string $msg [返回到的信息]
     * @param  array $data [数据]
     * @return [type] [string]
     */
	public function message($code,$msg='',$data=[]){
		$message = [
			'code' => $code,
			'msg' =>$msg,
			'data' => $data
		];
		echo json_encode($message);die;
	}
}